<?php
class Database {
	
	const HOST = "localhost";
	const DBNAME = "unionroom";
	const USER = "root";
	const PASSWORD = "";
	
	private $connection = null;
	
	/**
	* Baut die Verbindung zur Datenbank auf.
	*/
	public function __construct() {
		$this->connection = @mysql_pconnect(Database::HOST, Database::USER, Database::PASSWORD) or Core::error("Error beim Connect zur DB: " . mysql_error());
		@mysql_select_db(Database::DBNAME, $this->connection) or Core::error("Error beim Selektieren der DB: " . mysql_error());
	}
	
	
	public function sendQuery($sql){
		$erg = array();
		$i = 0;
		$result = @mysql_query($sql, $this->connection);
		
		if($result == false){
			echo mysql_error();
		}
		
  		while($row = mysql_fetch_array($result)){
  			$erg[$i] = $row;
  			$i++;
		}
		
		return $erg;
		
	}
	
	public function insertDate($sql){
		
		$result = @mysql_query($sql, $this->connection);
		
		if($result == false){
			echo mysql_error();
		}
	}

}

?>